package org.iabako.shared.entity.enumeration;

import org.iabako.client.tools.Messages;

/**
 * Created by jose on 04/05/15.
 */
public enum TrackingType implements LabelEnum {

    clientNew("tracking_client_new", true, false, false, false, false),
    clientModify("tracking_client_modify", true, false, false, false, false),
    clientDelete("tracking_client_delete", true, false, false, false, false),
    //clientDisable("tracking_client_disable", true, false, false, false, false),

    productNew("tracking_product_new", false, true, false, false, false),
    productModify("tracking_product_modify", false, true, false, false, false),
    productDelete("tracking_product_delete", false, true, false, false, false),
    //productDisable("tracking_product_disable", false, true, false, false, false),

    stockModification("tracking_stock_modify", false, true, false, false, false),

    serviceNew("tracking_service_new", false, false, true, false, false),
    serviceModify("tracking_service_modify", false, false, true, false, false),
    serviceDelete("tracking_service_delete", false, false, true, false, false),
    //serviceDisable("tracking_service_disable", false, false, true, false, false),

    saleDraft("tracking_sale_draft", false, false, false, true, false),
    saleNew("tracking_sale_new", false, false, false, true, false),
    saleModify("tracking_sale_modify", false, false, false, true, false),
    saleDelete("tracking_sale_delete", false, false, false, true, false),

    quoteDraft("tracking_quote_draft", false, false, false, true, false, true),
    quoteDiscard("tracking_quote_discard", false, false, false, true, false, true),
    quoteDownloaded("tracking_quote_downloaded", false, false, false, true, false, true),
    quoteSentByEmail("tracking_quote_sent_by_email", false, false, false, true, false, true),
    quoteTransformed("tracking_quote_transformed", false, false, false, true, false, true),
    quoteDelete("tracking_quote_delete", false, false, false, true, false, true),

    paymentReceivedNew("tracking_payment_received_new", false, false, false, true, false),
    paymentReceivedModify("tracking_payment_received_modify", false, false, false, true, false),
    paymentReceivedDelete("tracking_payment_received_delete", false, false, false, true, false),
    paymentReceivedToInstallment("tracking_payment_received_to_installment", false, false, false, true, false),

    installmentNew("tracking_installment_new", false, false, false, true, false),
    installmentModify("tracking_installment_modify", false, false, false, true, false),
    installmentDelete("tracking_installment_delete", false, false, false, true, false),
    installmentToPaymentReceived("tracking_installment_to_payment_received", false, false, false, true, false),

    invoiceDownloaded("tracking_invoice_downloaded", false, false, false, true, false),
    invoiceSentByEmail("tracking_invoice_sent_by_email", false, false, false, true, false),

    expenseNew("tracking_expense_new", false, false, false, false, true),
    expenseModify("tracking_expense_modify", false, false, false, false, true),
    expensePayed("tracking_expense_payed", false, false, false, false, true),
    expenseDelete("tracking_expense_delete", false, false, false, false, true),

    conversationNew("tracking_conversation_new", true, false, false, false, false),
    conversationModify("tracking_conversation_modify", true, false, false, false, false),
    conversationDelete("tracking_conversation_delete", true, false, false, false, false),

    communicationCreate("tracking_communication_new", false, false, false, false, false),
    reportGenerate("tracking_report_generate", false, false, false, false, false);

    private String labelKey;
    private boolean client;
    private boolean product;
    private boolean service;
    private boolean sale;
    private boolean expense;
    private boolean quote;

    TrackingType(String labelKey, boolean client, boolean product, boolean service, boolean sale, boolean expense) {
        this(labelKey, client, product, service, sale, expense, false);
    }

    TrackingType(String labelKey, boolean client, boolean product, boolean service, boolean sale, boolean expense, boolean quote) {
        this.labelKey = labelKey;
        this.client = client;
        this.product = product;
        this.service = service;
        this.sale = sale;
        this.expense = expense;
        this.quote = quote;
    }

    public String getLabel() {
        return Messages.getLabel(labelKey);
    }

    public String getLabelKey() {
        return labelKey;
    }

    public boolean isClient() {
        return client;
    }

    public boolean isProduct() {
        return product;
    }

    public boolean isService() {
        return service;
    }

    public boolean isSale() {
        return sale;
    }

    public boolean isExpense() {
        return expense;
    }

    public boolean isQuote() {
        return quote;
    }

    public boolean isDeleteBusinessObject() {
        return this == clientDelete
                || this == productDelete
                || this == serviceDelete
                || this == saleDelete
                || this == quoteDelete
                || this == expenseDelete;
    }
}
